// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PicknPlaceAgentUr5Ax12.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Microsoft.Robotics.Manipulation.Runtime
{
    using System;
    using System.Runtime.Serialization;
    using Microsoft.Robotics.Hardware;
    using Microsoft.Robotics.Hardware.Robotiq;
    using Microsoft.Robotics.Hardware.Runtime.Robotiq;
    using Microsoft.Robotics.Manipulation.PicknPlace;
    using Microsoft.Robotics.Numerics;
    using Microsoft.Robotics.Runtime;
    using Microsoft.Robotics.Tracing;

    /// <summary>
    /// Handles higher level "pick" and "place" commands for a UR5 plus AX12 Dynamixel gripper. 
    /// </summary>
    [DataContract]
    public class PicknPlaceAgentUr5Ax12 : PicknPlaceAgentKukaRobotiq
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PicknPlaceAgentUr5Ax12" /> class
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="producer">The name of the agent we subscribe to.</param>
        /// <param name="armControlAgentName">Name of the arm control agent</param>
        /// <param name="handControlAgentName">Name of the hand control agent</param>
        /// <param name="handStatusProvider">Name of agent providing integrated arm / hand status</param>
        /// <param name="armMoveRotationalTolerance">Tolerance on arm orientation moves in radians</param>
        /// <param name="armMoveTranslationalTolerance">Tolerance on arm move convergence in meters</param>
        /// <param name="liftHeight">Lift height from grasp position</param>
        /// <param name="defaultSubTaskStepTimeOutmSec">Time out in mSec at each step in pick and place tasks</param>
        /// <param name="gripExchangePose">Location used for grip exchange</param>
        /// <param name="defaultNeutralPose">Default neutral position before a pick or place</param>
        public PicknPlaceAgentUr5Ax12(
            string name,
            IProducer<ManipulatorStatusMessage> producer,
            string armControlAgentName,
            string handControlAgentName,
            string handStatusProvider,
            double armMoveRotationalTolerance,
            double armMoveTranslationalTolerance,
            double liftHeight,
            int defaultSubTaskStepTimeOutmSec,
            Pose gripExchangePose,
            Pose defaultNeutralPose)
            : base(name, producer, armControlAgentName, handControlAgentName, handStatusProvider, armMoveRotationalTolerance, armMoveTranslationalTolerance, liftHeight, defaultSubTaskStepTimeOutmSec, gripExchangePose, defaultNeutralPose)
        {
        }

        /// <summary>
        /// Initializes the agent
        /// </summary>
        /// <param name="locator">Agent locator to use</param>
        public override void Initialize(AgentLocator locator)
        {
            base.Initialize(locator);
            this.PicknPlaceGenerator = new PicknPlaceTaskDescriptionGenerator(new PicknPlaceUr5Ax12DualGrip(), this.DefaultSubTaskStepTimeOutmSec);
        }
    }
}
